package com.ler.yrmall.product.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.ler.yrmall.basic.BaseEntity;
import com.ler.yrmall.enums.BasicStatusEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * @author Leron
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "pms_attr",autoResultMap = true)
public class AttrEntity extends BaseEntity<AttrEntity> {


    /**
     * 属性名称
     */
    private String name;

    /**
     * 是否可检索
     * @see com.ler.yrmall.enums.BasicStatusEnum.SystemEnableStatus
     */
    private Integer searchType;

    /**
     * 服务图标
     */
    private String icon;

    /**
     * 可选值
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> optionalValue;

    /**
     * 是否支持多选
     * @see ValueType
     */
    private Integer valueType;

    /**
     * 属性类型
     * @see AttrType
     */
    private Integer attrType;

    /**
     * 是否启用
     * @see BasicStatusEnum.SystemEnableStatus
     */
    private Long enable;

    /**
     * 分类id
     */
    private Long categoryId;

    /**
     *
     */
    private Integer quickShow;

    public enum ValueType {

        /**
         * 单个值
         */
        SINGLE(1),

        /**
         * 多个值
         */
        MULTIPLE(0);

        private final Integer code;

        ValueType(Integer code) {
            this.code = code;
        }

        public Integer getCode() {
            return code;
        }
    }

    public enum AttrType {

        /**
         * 基础属性
         */
        BASIC(1),

        /**
         * 销售属性
         */
        SALE(0);

        private final Integer code;

        AttrType(Integer code) {
            this.code = code;
        }

        public Integer getCode() {
            return code;
        }
    }

}
